package cn.zysuyuan.item.service.impl;

import cn.zysuyuan.common.entity.PageResult;
import cn.zysuyuan.common.utils.UUIDUtil;
import cn.zysuyuan.item.entity.Device;
import cn.zysuyuan.item.mapper.DeviceMapper;
import cn.zysuyuan.item.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author flypig
 * @version 1.0
 * @date 2019/10/28 14:06
 */

@Service
public class DeviceServiceImpl implements DeviceService {

    @Autowired
    private DeviceMapper deviceMapper;

    @Override
    public PageResult<Device> queryDevicesByPage(Map<String,Object> map) {

        List<Device> devices = this.deviceMapper.selectList(map);

        // 包装成分页的结果集返回
        return new PageResult<Device>(devices);
    }

    @Override
    public int insert(Device device) {
        device.setId(UUIDUtil.uuid());
        device.settCreateTime(new Date());
        return deviceMapper.insert(device);
    }

    @Override
    public int update(Device device) {
        return deviceMapper.update(device);
    }

    @Override
    public int delete(String id) {
        return deviceMapper.delete(id);
    }
}
